package com.ssm.converter;

import org.springframework.core.convert.converter.Converter;

/**
 * @program: exercise1_online_shopping
 * @author: qin haojun
 * @create: 2021-02-18 13:39
 */
public class IntegerArrayConverter implements Converter<String[],Integer[]> {

    @Override
    public Integer[] convert(String[] strings) {
        // 判断
        if(strings == null){
            //抛出运行异常
            throw new RuntimeException("请您传入数据");
        }

        int len=strings.length;
        Integer[] integers=new Integer[len];
        for(int i=0;i<len;i++){
            integers[i]=Integer.parseInt(strings[i]);
        }
        return integers;
    }
}
